﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Keywords>
        <Keyword>
        </Keyword>
      </Keywords>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>ParseTypeName</Title>
      <Author>innovoCAD</Author>
      <Description>Parse a type name into MSElementType.</Description>
      <HelpUrl>
      </HelpUrl>
      <Shortcut>MSCEParseTypeName</Shortcut>
    </Header>
    <Snippet>
      <References>
        <Reference>
          <Assembly>Bentley.DgnPlatformNET</Assembly>
        </Reference>
      </References>
      <Imports>
        <Import>
          <Namespace>BDPN = Bentley.DgnPlatformNET</Namespace>
        </Import>
        <Import>
          <Namespace>System</Namespace>
        </Import>
        <Import>
          <Namespace>System.Collections.Generic</Namespace>
        </Import>
      </Imports>
      <Declarations>
      </Declarations>
      <Code Language="vb" Kind="method decl" Delimiter="$"><![CDATA[''' <summary>
''' Parse type name (e.g. 'line') into MSElementType[] 
''' </summary>
''' <param name="unParsedTypeName"></param>
''' <returns></returns>
Private Function ParseTypeName(unParsedTypeName As String) As BDPN.MSElementType()
	'TODO: Modify or add to list.
	Dim typeNameList As New List(Of BDPN.MSElementType)()
	Dim parseType As String() = unParsedTypeName.Split(New [Char]() {","C}, System.StringSplitOptions.RemoveEmptyEntries)
	For Each typeName As String In parseType
		Dim elemType As BDPN.MSElementType = BDPN.MSElementType.None
		Select Case typeName.Trim().ToLower()
			Case "cell"
				elemType = BDPN.MSElementType.CellHeader
				Exit Select
			Case "shared", "sharedcell"
				elemType = BDPN.MSElementType.SharedCellInstance
				Exit Select
			Case "line", "lines"
				elemType = BDPN.MSElementType.Line
				Exit Select
			Case "lstring", "linestring"
				elemType = BDPN.MSElementType.LineString
				Exit Select
			Case "arc"
				elemType = BDPN.MSElementType.Arc
				Exit Select
			Case "circle", "ellipse"
				elemType = BDPN.MSElementType.Ellipse
				Exit Select
			Case "polygon", "shape"
				elemType = BDPN.MSElementType.Shape
				Exit Select
			Case "tag", "tags"
				elemType = BDPN.MSElementType.Tag
				Exit Select
			Case "text"
				elemType = BDPN.MSElementType.Text
				Exit Select
			Case "node", "textnode"
				elemType = BDPN.MSElementType.TextNode
				Exit Select
		End Select
		typeNameList.Add(elemType)
	Next
	Return typeNameList.ToArray()
End Function]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>